﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using BeatEmUp.Movement;
using BeatEmUp.HUD;
using BeatEmUp.Animation;

namespace BeatEmUp.Characters
{
    abstract class Character
    {
        protected MovementAbstr move;
        protected Texture2D characterTextureL;
        protected Texture2D characterTextureR;
        protected Rectangle collisionRec;
        protected Stats stats;
        public HPDisplay characterHP{protected set;get;}
        protected GameTime gameTime;
        protected AnimationManager am = new AnimationManager(new Vector2(30, 51), 4,4, 300.0f);

        public Character(Rectangle startingPosition, Texture2D pTextureL, Texture2D pTextureR, GameTime gameTime)
        {
            this.gameTime = gameTime;
            stats = new Stats();
            characterTextureL = pTextureL;
            characterTextureR = pTextureR;
            collisionRec = new Rectangle(startingPosition.X, startingPosition.Y+startingPosition.Height-startingPosition.Height/3, startingPosition.Width, startingPosition.Height / 3);
        }

        public Texture2D CharacterTexture
        {
            get
            {
                switch (move.FaceDirection)
                {
                    case FaceDirectionEnum.Right:
                       
                        return characterTextureR;
                    case FaceDirectionEnum.Left:


                        return characterTextureL;
                }
                return characterTextureR;
            }
        }
        public void setFaceDirection(FaceDirectionEnum fde)
        {
            move.FaceDirection = fde;
        }

        public FaceDirectionEnum getFaceDirection()
        {

            return move.FaceDirection;
        }

        public bool isAttacking
        {
            get;
            set;
        }
        public Rectangle CollisionRec
        {
            get { return collisionRec; }
        }
        protected void UpdateCollisionRec()
        {
            collisionRec.X = move.Position.X;
            collisionRec.Y = move.Position.Y + move.Position.Height - move.Position.Height / 3;
        }

        public int HP
        {
            get { return stats.hp; }
            set { stats.hp = value; }
        }
        
        public int MaxHP
        {
            get { return stats.maxHp; }
            set { }
        }
        
        public float HPPercentage()//Późniejsza metoda klasy hp postaci i przeciwnika
        {
            return ((float)stats.hp / (float)stats.maxHp) * 100;
        }
        public int Attack()
        {
            return stats.giveMeAttackPower();
        }
    }
}
